home *** CD-ROM | disk | FTP | other *** search
- /*
- sc_sk_misc.c - general scope window routines
- */
- #include <EventMgr.h>
- #include "sc.h"
- #include "sc_filter.h"
- #include "sc_scope_window.h"
-
- #define CHAN_HEIGHT 24 /* pixels between channels*/
- #define MAX_CHAN_VALUE (CHAN_HEIGHT-1)
-
- void e_sk_activate()
- {
- }
-
- void e_sk_deactivate()
- {
- }
-
- /* clip_normal - set a windows clipping to the default, full window clip
- */
- void clip_normal(WindowPtr);
- void clip_normal(a_win)
- WindowPtr a_win;
- {RectRgn(a_win->clipRgn,&a_win->portRect);
- }
-
- /*
- show_grow - draw the grow icon for only having a vertical
- scroll bar
- */
- void show_grow()
- {Rect clip_rect;
- clip_rect=CUR_WINDOW->portRect;
- clip_rect.left=clip_rect.right - SCROLL_BAR_PIXLS + 1;
- RectRgn(CUR_WINDOW->clipRgn,&clip_rect);
- DrawGrowIcon(CUR_WINDOW);
- clip_normal(CUR_WINDOW);
- }
-
- void e_scope_update_event()
- {register int i;
- cnt_tab_ent *cur_cnt;
- show_grow();
- MoveTo(gl.cur_windef->char_left_inset,CHAN_HEIGHT);
- for(i=0;i<NUM_SCOPE_CHANS;i++) {
- cur_cnt= SK_wdf->chans[i].sc_counter;
- if(cur_cnt==NIL)
- break;
- DrawString(RES_pstr(cur_cnt->filname));
- MoveTo(gl.cur_windef->char_left_inset,
- CUR_WINDOW->pnLoc.v+CHAN_HEIGHT);
- }
- }
-
- void e_scope_grow(where)
- Point where;
- {Rect r;
- union {
- long grow_as_long;
- Point grow_to;
- } grow_result;
- /* say how big/small a packet window can be*/
- /*quickdraw vars aren't around for a da to get screen bits*/
- SetRect(&r,70,70,CUR_WINDOW->portBits.bounds.right,CUR_WINDOW->portBits.bounds.bottom);
- grow_result.grow_as_long=
- GrowWindow(CUR_WINDOW,where,&r); /* see how big to make it*/
-
-
- r=CUR_WINDOW->portRect; /*invalidate the old scroll areas*/
- r.left=r.right-SCROLL_BAR_PIXLS+1;
- InvalRect(&r);
- SizeWindow(CUR_WINDOW,
- grow_result.grow_to.h,
- grow_result.grow_to.v,TRUE); /*grow it, update update region*/
- RectRgn(CUR_WINDOW->clipRgn,&CUR_WINDOW->portRect);
-
- r=CUR_WINDOW->portRect; /*invalidate the new scroll areas*/
- r.left=r.right-SCROLL_BAR_PIXLS+1;
- InvalRect(&r);
-
- SK_wdf->skw_endx=(CUR_WINDOW->portRect.right-SCROLL_BAR_PIXLS);
- }
-
- void e_scope_down_content(the_event)
- EventRecord *the_event;
- {Point down_at; /*where the mouse went down*/
- down_at=the_event->where; /*say where mouse went down*/
- GlobalToLocal(&down_at); /*find control likes local coordinates*/
- /* if down where the grow area would be, pretend it we should
- grow. DA windows can't grow normaly so we check down in grow here
- Probably should also check active
- */
- if((down_at.h>(CUR_WINDOW->portRect.right-SCROLL_BAR_PIXLS))&&
- (down_at.v>(CUR_WINDOW->portRect.bottom-SCROLL_BAR_PIXLS)))
- e_scope_grow(the_event->where);
- }
-
- #define CHAN_LEFT 60 /* left edge of display*/
- static int scope_x_pos=CHAN_LEFT;
- /*
- one tick happened, draw the updated counters
- */
- void scope_tick()
- {register int i;
- register scope_rec *scan_rec;
- register int channel_value;
- cnt_tab_ent *cur_cnt;
- WindowPtr save_window; /*the graf port before the update*/
- windef *save_windef; /*pointer to our per window information*/
-
- if(gl.wdf_scope==NIL) /*have a scope window?*/
- return; /*no, nothing to draw then*/
- GetPort(&save_window);
- save_windef=gl.cur_windef; /*change the windef with the port*/
- gl.cur_windef= gl.wdf_scope;
- SetPort(CUR_WINDOW); /*switch to the port to update*/
-
- scan_rec = SK_wdf->chans; /* scan each channel */
- scope_x_pos++; /*paint in the next x position*/
- if(scope_x_pos>= SK_wdf->skw_endx)
- scope_x_pos = CHAN_LEFT;
- /*erase the current position*/
- {register int ahead_x;
- PenMode(notPatCopy);
- ahead_x = scope_x_pos + 8;
- if(ahead_x>= SK_wdf->skw_endx)
- ahead_x -= SK_wdf->skw_endx-CHAN_LEFT;
- MoveTo(ahead_x,CUR_WINDOW->portRect.top);
- LineTo(ahead_x,CUR_WINDOW->portRect.bottom);
- PenNormal();
- } /* end register ahead_x */
- for(i=1;i<=NUM_SCOPE_CHANS;i++) {
- cur_cnt=scan_rec->sc_counter; /* pointer to the current counter */
- if(cur_cnt==NIL) /* stop when out of counters */
- break;
- channel_value=(cur_cnt->count-scan_rec->sc_value);
- channel_value=max(0,channel_value);
- channel_value=min(MAX_CHAN_VALUE,channel_value);
- scan_rec->sc_value=cur_cnt->count;
- MoveTo(scope_x_pos,CHAN_HEIGHT*i-channel_value-
- gl.cur_windef->char_descent);
- Line(0,0);
- scan_rec++; /*step to the next channel*/
- }
-
- SetPort(save_window);
- gl.cur_windef=save_windef;
- }
-